﻿@using XinYue.Permission.Mode;
@{
    Menu menu = new Menu();
    if (@ViewBag.Menu!=null)
    {
        menu = @ViewBag.Menu;
    }
}
@*@{
        Layout = null;
        var AmdinRoleList = @ViewBag.AdminRoleList;
        var count = ViewBag.count;
    }*@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="renderer" content="webkit|ie-comp|ie-stand" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link href="~/assets/css/bootstrap.min.css" rel="stylesheet" />
    <link rel="stylesheet" href="~/Content/style.css" />
    <link href="~/assets/css/codemirror.css" rel="stylesheet" />
    <link rel="stylesheet" href="~/assets/css/ace.min.css" />
    <link rel="stylesheet" href="~/font/css/font-awesome.min.css" />
    <link rel="stylesheet" href="~/layui/css/layui.css" />
    <!--[if lte IE 8]>
      <link rel="stylesheet" href="~/assets/css/ace-ie.min.css" />
    <![endif]-->
    <script type="text/javascript" src="~/Scripts/jquery-3.3.1.min.js"></script>
    <script src="~/Scripts/jquery-1.9.1.min.js"></script>
    <script src="~/assets/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="~/Widget/Validform/5.3.2/Validform.min.js"></script>
    <script src="~/assets/js/typeahead-bs2.min.js"></script>
    <script src="~/assets/js/jquery.dataTables.min.js"></script>
    <script src="~/assets/js/jquery.dataTables.bootstrap.js"></script>
    <script src="~/assets/layer/layer.js" type="text/javascript"></script>
    <script src="~/Scripts/lrtk.js" type="text/javascript"></script>
    <script src="~/assets/layer/layer.js" type="text/javascript"></script>
    <script src="~/assets/laydate/laydate.js" type="text/javascript"></script>
    <script src="~/layui/layui.js" type="text/javascript"></script>
    <script src="~/Timejs/Time.js" type="text/javascript"></script>
    <title>管理员</title>
</head>

<body class="childrenBody">
    <form class="layui-form">
        <input id="Id" type="hidden" value="@menu.Id" />
        <div class="layui-form-item">
            <label class="layui-form-label">菜单名称</label>
            <div class="layui-input-block">
                <input id="Name" type="text" class="layui-input newsName" lay-verify="required" placeholder="菜单名称" value="@menu.Name" />
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">组Id</label>
            <div class="layui-input-block">
                <input id="ModuleId" type="text" class="layui-input newsName" lay-verify="required" placeholder="菜单地址" value="@menu.ModuleId" />
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">父级菜单Idv</label>
            <div class="layui-input-block">
                <input id="ParentId" type="text" class="layui-input newsName" lay-verify="required" placeholder="菜单地址" value="@menu.ParentId" />
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">菜单地址</label>
            <div class="layui-input-block">
                <input id="Url" type="text" class="layui-input newsName" lay-verify="required" placeholder="菜单地址" value="@menu.Url" />
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">菜单图标</label>
            <div class="layui-input-block">
                <input id="Icon" type="text" class="layui-input newsName" lay-verify="required" placeholder="菜单图标" value="@menu.Icon" />
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">排序Id</label>
            <div class="layui-input-block">
                <input id="SortId" type="text" class="layui-input newsName" lay-verify="required" placeholder="菜单图标" value="@menu.SortId" />
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">创建人</label>
            <div class="layui-input-block">
                <input id="CreateUserId" type="text" class="layui-input newsName" lay-verify="required" placeholder="创建人" value="@menu.CreateUserId" />
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">创建时间</label>
            <div class="layui-input-block">
                <input id="CreateTime" type="text" class="layui-input newsName" lay-verify="required" placeholder="yyyy-MM-dd" value="@menu.CreateTime" />
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">是否显示</label>
            <input name="radio" type="radio" id="radio" value="0" checked="checked" />
            <label for="radio"></label>
            隐藏
            <input type="radio" name="radio" id="radio2" value="1" />
            显示
            <label for="radio2"></label>
        </div>


        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" id="btn" lay-submit="" lay-filter="addNews">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
    <script type="text/javascript" src="~/layui/layui.js"></script>
    <script type="text/javascript" src="~/page/news/newsAdd.js"></script>
</body>
</html>
<script src="~/Scripts/timeTranslation.js"></script>
<script>
    //添加信息
    $("#btn").click(function () {
        var array = {};
        array.Name = $("#Name").val();
        array.ModuleId = $("#ModuleId").val();
        array.ParentId = $("#ParentId").val();
        array.Url = $("#Url").val();
        array.Icon = $("#Icon").val();
        array.SortId = $("#SortId").val();
        array.CreateUserId = $("#CreateUserId").val();
        array.CreateTime = $("#CreateTime").val();
        array.Id = $("#Id").val();
        $.ajax({
            url: "/Menu/AddingInformation",
            type: "post",
            data: array,
            success: function (result) {
                if (result.Success) {
                    if (array.Id != 0) {
                        layer.msg("修改成功", function () {
                            location.reload();//刷新页面
                            window.location.href = '/Home/Menu ';
                        });
                    } else {
                        layer.msg("添加成功", function () {
                            location.reload();//刷新页面
                        });
                    }
                }
                else {
                    if (array.Id != 0) {
                        layer.msg("修改失败");//刷新页面
                    } else {
                        layer.msg("添加失败");//刷新页面
                    }
                }
            }
        })
    })
</script>